package com.kuzlak.cms.exception;


import com.kuzlak.cms.bean.Result;
import com.kuzlak.cms.constant.ResultConstant;

public class SysErrorException extends Exception {
    private static final long serialVersionUID = -6357149550353160810L;
    private Result error;

    public SysErrorException(String message) {
        super(message);
        this.error = new Result();
        this.error.setCode(ResultConstant.FAIL);
        this.error.setMsg(message);
        //    this(Result.builder().errorCode(-1).errorMsg(message).build());
    }

    public SysErrorException(int status) {
        super("");
        this.error = new Result();
        this.error.setCode(status);

        //    this(Result.builder().errorCode(-1).errorMsg(message).build());
    }

    public SysErrorException(Result error) {
        super(error.toString());

        this.error = error;
    }

    public SysErrorException(Result error, Throwable cause) {
        super(error.toString(), cause);
        this.error = error;
    }

    public SysErrorException(Throwable cause) {
        super(cause.getMessage(), cause);
        this.error.setCode(ResultConstant.FAIL);
        this.error.setMsg(cause.getMessage());
        //  this.error = Result.builder().errorCode(-1).errorMsg(cause.getMessage()).build();
    }

    public Result getError() {
        return this.error;
    }

}